<?php
class M_Tool_DataFilter {
    public function arrayFilter($array, $keys, $exclude=false) {
        if($exclude) {
            $arr = $array;
            foreach ($keys as $k) {
                if(isset($arr[$k])) {
                    unset($arr[$k]);
                }
            }
        } else {
            $arr = array();
            foreach ($keys as $k) {
                if(isset($array[$k])) {
                    $arr[$k] = $array[$k];
                }
            }
        }

        return $arr;
    }

    public function exists(Zend_Db_Select $select) {
        $s = clone $select;
        $s->reset(Zend_Db_Select::COLUMNS)
          ->columns(new Zend_Db_Expr('1'))
          ->limit(1);
        $r = !!$s->query()->fetch();

        $s = null;
        return $r;
    }
}
